<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="性别" prop="gender">
        <el-input
          v-model="queryParams.gender"
          placeholder="请输入性别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生年月" prop="birthday">
        <el-date-picker clearable
          v-model="queryParams.birthday"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择出生年月">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="籍贯" prop="nativePlace">
        <el-input
          v-model="queryParams.nativePlace"
          placeholder="请输入籍贯"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="政治面貌" prop="politicalOutlook">
        <el-select v-model="queryParams.politicalOutlook" placeholder="政治面貌">
          <el-option
            v-for="item in politicalOutlookOptions"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          ></el-option>
        </el-select>
      </el-form-item>
<!--      <el-form-item label="婚姻" prop="marriage">
        <el-input
          v-model="queryParams.marriage"
          placeholder="请输入婚姻"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="学历" prop="education">
        <el-select v-model="queryParams.education" placeholder="学历">
          <el-option
            v-for="item in educationOptions"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          ></el-option>
        </el-select>
      </el-form-item>
<!--      <el-form-item label="专业" prop="speciality">
        <el-input
          v-model="queryParams.speciality"
          placeholder="请输入专业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="职称" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入职称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号码" prop="idCardNumber">
        <el-input
          v-model="queryParams.idCardNumber"
          placeholder="请输入身份证号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="毕业院校" prop="graduationSchool">
        <el-input
          v-model="queryParams.graduationSchool"
          placeholder="请输入毕业院校"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="毕业时间" prop="graduationTime">
        <el-date-picker clearable
          v-model="queryParams.graduationTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择毕业时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="联系电话" prop="telephone">
        <el-input
          v-model="queryParams.telephone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small"
                   @change="handleQuery"
        >
          <el-option label="待入职" value="0"/>
          <el-option label="已入职" value="1"/>
          <el-option label="已离职" value="2"/>
        </el-select>
      </el-form-item>
<!--      <el-form-item label="联系地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入联系地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="紧急联系人名称" prop="contactName">
        <el-input
          v-model="queryParams.contactName"
          placeholder="请输入紧急联系人名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="紧急联系人关系" prop="relationship">
        <el-input
          v-model="queryParams.relationship"
          placeholder="请输入紧急联系人关系"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="紧急联系人电话" prop="contactTelephone">
        <el-input
          v-model="queryParams.contactTelephone"
          placeholder="请输入紧急联系人电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="入职时间" prop="entryTime">
        <el-date-picker clearable
          v-model="queryParams.entryTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择入职时间">
        </el-date-picker>
      </el-form-item>
<!--      <el-form-item label="入职职务" prop="post">
        <el-input
          v-model="queryParams.post"
          placeholder="请输入入职职务"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试用薪资" prop="probationSalary">
        <el-input
          v-model="queryParams.probationSalary"
          placeholder="请输入试用薪资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="转正薪资" prop="fullMemberSalay">
        <el-input
          v-model="queryParams.fullMemberSalay"
          placeholder="请输入转正薪资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input
          v-model="queryParams.email"
          placeholder="请输入邮箱"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['module:staff:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >修改</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['module:staff:delete']"
        >删除</el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['module:staff:export']"
        >导出</el-button>
      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="staffList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="gender" />
      <el-table-column label="出生年月" align="center" prop="birthday" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="籍贯" align="center" prop="nativePlace" />
      <el-table-column label="政治面貌" align="center" prop="politicalOutlook" />
      <el-table-column label="婚姻" align="center" prop="marriage" />
      <el-table-column label="学历" align="center" prop="education" />
      <el-table-column label="专业" align="center" prop="speciality" />
      <el-table-column label="职称" align="center" prop="title" />
      <el-table-column label="身份证号码" align="center" prop="idCardNumber" />
      <el-table-column label="毕业院校" align="center" prop="graduationSchool" />
      <el-table-column label="毕业时间" align="center" prop="graduationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.graduationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="telephone" />
      <el-table-column label="联系地址" align="center" prop="address" />
      <el-table-column label="紧急联系人名称" align="center" prop="contactName" />
      <el-table-column label="紧急联系人关系" align="center" prop="relationship" />
      <el-table-column label="紧急联系人电话" align="center" prop="contactTelephone" />
<!--      <el-table-column label="个人照片" align="center" prop="personalPhotos" />
      <el-table-column label="学历照片" align="center" prop="educationalPhotos" />
      <el-table-column label="其他证书照片" align="center" prop="otherCertificatePhotos" />
      <el-table-column label="离职证明照片" align="center" prop="leavingCertificatePhotos" />
      -->
      <el-table-column label="技能" align="center" prop="skill" />
      <el-table-column label="入职时间" align="center" prop="entryTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.entryTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="入职部门" align="center" prop="deptName" />
      <el-table-column label="入职职务" align="center" prop="post" />
      <el-table-column label="试用薪资(元)" align="center" prop="probationSalary" />
      <el-table-column label="转正薪资(元)" align="center" prop="fullMemberSalay" />
      <el-table-column label="开户行" align="center" prop="bank" />
      <el-table-column label="银行卡号" align="center" prop="bankCardNo" />

      <el-table-column label="邮箱" align="center" prop="email" />
      <el-table-column label="状态" align="center" prop="status" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == '0'" type="info">待入职</el-tag>
          <el-tag v-if="scope.row.status == '1'" type="success">已入职</el-tag>
          <el-tag v-if="scope.row.status == '2'" type="danger">已离职</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['module:staff:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['module:staff:delete']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改员工对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<!--        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-input v-model="form.gender" placeholder="请输入性别" />
        </el-form-item>
        <el-form-item label="出生年月" prop="birthday">
          <el-date-picker clearable
            v-model="form.birthday"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生年月">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="籍贯" prop="nativePlace">
          <el-input v-model="form.nativePlace" placeholder="请输入籍贯" />
        </el-form-item>
        <el-form-item label="政治面貌" prop="politicalOutlook">
          <el-input v-model="form.politicalOutlook" placeholder="请输入政治面貌" />
        </el-form-item>
        <el-form-item label="婚姻" prop="marriage">
          <el-input v-model="form.marriage" placeholder="请输入婚姻" />
        </el-form-item>
        <el-form-item label="学历" prop="education">
          <el-input v-model="form.education" placeholder="请输入学历" />
        </el-form-item>
        <el-form-item label="专业" prop="speciality">
          <el-input v-model="form.speciality" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="职称" prop="title">
          <el-input v-model="form.title" placeholder="请输入职称" />
        </el-form-item>
        <el-form-item label="身份证号码" prop="idCardNumber">
          <el-input v-model="form.idCardNumber" placeholder="请输入身份证号码" />
        </el-form-item>
        <el-form-item label="毕业院校" prop="graduationSchool">
          <el-input v-model="form.graduationSchool" placeholder="请输入毕业院校" />
        </el-form-item>
        <el-form-item label="毕业时间" prop="graduationTime">
          <el-date-picker clearable
            v-model="form.graduationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择毕业时间">
          </el-date-picker>
        </el-form-item>-->
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="联系电话" prop="telephone">
          <el-input v-model="form.telephone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="联系地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入联系地址" />
        </el-form-item>
        <el-form-item label="开户行" prop="bank">
          <el-input v-model="form.bank" placeholder="请输入开户行" />
        </el-form-item>
        <el-form-item label="银行卡号" prop="bankCardNo">
          <el-input v-model="form.bankCardNo" placeholder="请输入银行卡号" />
        </el-form-item>
        <el-form-item label="紧急联系人名称" prop="contactName">
          <el-input v-model="form.contactName" placeholder="请输入紧急联系人名称" />
        </el-form-item>
        <el-form-item label="紧急联系人关系" prop="relationship">
          <el-input v-model="form.relationship" placeholder="请输入紧急联系人关系" />
        </el-form-item>
        <el-form-item label="紧急联系人电话" prop="contactTelephone">
          <el-input v-model="form.contactTelephone" placeholder="请输入紧急联系人电话" />
        </el-form-item>
        <el-form-item label="个人照片" prop="personalPhotos">
          <el-upload
            action="#"
            :http-request="requestUpload"
            :show-file-list="false"
            :before-upload="beforeUpload"
          >
            <el-button size="small" v-if="!form.personalPhotos">
              选择
              <i class="el-icon-upload"></i>
            </el-button>
            <img v-else :src="form.personalPhotosShow" class="avatar" height="80">
          </el-upload>
        </el-form-item>
        <el-form-item label="学历照片" prop="educationalPhotos">
          <el-upload
            action="#"
            :http-request="requestUpload"
            :show-file-list="false"
            :before-upload="beforeUpload2"
          >
            <el-button size="small" v-if="!form.educationalPhotos">
              选择
              <i class="el-icon-upload"></i>
            </el-button>
            <img v-else :src="form.educationalPhotosShow" class="avatar" height="80">
          </el-upload>
        </el-form-item>
        <el-form-item label="离职证明照片" prop="leavingCertificatePhotos">
          <el-upload
            action="#"
            :http-request="requestUpload"
            :show-file-list="false"
            :before-upload="beforeUpload3"
          >
            <el-button size="small" v-if="!form.leavingCertificatePhotos">
              选择
              <i class="el-icon-upload"></i>
            </el-button>
            <img v-else :src="form.leavingCertificatePhotosShow" class="avatar" height="80">
          </el-upload>
        </el-form-item>
        <el-form-item label="其他证书照片" prop="otherCertificatePhotos">
          <el-upload
            action="#"
            :http-request="requestUpload"
            :before-upload="beforeUpload4"
            :show-file-list="false"
          >
            <el-button size="small" v-if="!form.otherCertificatePhotos">
              选择
              <i class="el-icon-upload"></i>
            </el-button>
            <img v-else :src="form.otherCertificatePhotosShow" class="avatar" height="80">
          </el-upload>
        </el-form-item>
        <el-form-item label="技能" prop="skill">
          <el-input v-model="form.skill" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="入职时间" prop="entryTime">
          <el-date-picker clearable
            v-model="form.entryTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入职时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="入职部门" prop="deptName">
          <el-input v-model="form.deptName"  placeholder="">
            <template slot="append">
              <el-button type="primary" style="width: 120px" @click="openImportDept">
                选择部门
              </el-button>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item label="入职职务" prop="post">
          <el-input v-model="form.post" placeholder="请输入入职职务" />
        </el-form-item>

        <el-form-item label="试用薪资(元)" prop="probationSalary">
          <el-input v-model="form.probationSalary" placeholder="请输入试用薪资" />
        </el-form-item>
        <el-form-item label="转正薪资(元)" prop="fullMemberSalay">
          <el-input v-model="form.fullMemberSalay" placeholder="请输入转正薪资" />
        </el-form-item>

        <el-form-item label="状态" prop="status">
          <el-select v-model="form.status" placeholder="请选择状态" clearable size="small"
                     @change="handleQuery"
          >
            <el-option label="待入职" value="0"/>
            <el-option label="已入职" value="1"/>
            <el-option label="已离职" value="2"/>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <import-dept ref="importDept" @showDept="showDept"></import-dept>
  </div>
</template>

<script>
import { listStaff, getStaff, delStaff, addStaff, updateStaff } from "@/api/module/staff";
import { getDicts } from '@/api/system/dict/data';
import { uploadImageFile } from '@/api/tool/gen';
import importDept from "@/views/module/warehouse/dept";


export default {
  name: "Staff",
  components: {importDept},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 员工表格数据
      staffList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        gender: null,
        birthday: null,
        nativePlace: null,
        politicalOutlook: null,
        marriage: null,
        education: null,
        speciality: null,
        title: null,
        idCardNumber: null,
        graduationSchool: null,
        graduationTime: null,
        telephone: null,
        address: null,
        contactName: null,
        relationship: null,
        contactTelephone: null,
        personalPhotos: null,
        educationalPhotos: null,
        otherCertificatePhotos: null,
        skill: null,
        entryTime: null,
        post: null,
        probationSalary: null,
        fullMemberSalay: null,
        leavingCertificatePhotos: null,
        email: null,
        status: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        probationSalary: [
          {
            required: true,
            message: '试用薪资不能为空',
            trigger: 'blur'
          },
          {
            validator: (rule, value, callback) => {
              if (/^[0-9]*$/.test(value) == false) {
                callback(new Error('试用薪资必须为纯数字'))
              } else {
                callback()
              }
            },
            trigger: 'blur'
          }
        ],
        fullMemberSalay: [
          {
            required: true,
            message: '转正薪资不能为空',
            trigger: 'blur'
          },
          {
            validator: (rule, value, callback) => {
              if (/^[0-9]*$/.test(value) == false) {
                callback(new Error('转正薪资必须为纯数字'))
              } else {
                callback()
              }
            },
            trigger: 'blur'
          }
        ],
        telephone: [
          {
            required: true,
            message: '请输入正确的手机号码',
            trigger: 'blur'
          },
          {
            validator: (rule, value, callback) => {
              if (/^1[3-9]\d{9}$/.test(value) == false) {
                callback(new Error('请输入11位手机号'))
              } else {
                callback()
              }
            },
            trigger: 'blur'
          }
      ]
      },
      // 学历
      educationOptions: [],
      // 政治面貌
      politicalOutlookOptions: [],
      dialogVisible: false,
    };
  },
  created() {
    this.getList();
    this.getEducationOptions();
    this.getPoliticalOutlookOptions();
  },
  methods: {
    /** 打开部门弹窗 */
    openImportDept() {
      this.$refs.importDept.show();
    },
    showDept(data){
      //部门
      this.form.dept=data.deptId;
      this.form.deptName=data.deptName;
    },
    /** 查询员工列表 */
    getList() {
      this.loading = true;
      listStaff(this.queryParams).then(response => {
        this.staffList = response.rows;
        // 产品类型判断
        let arr = this.staffList;
        arr.forEach(item => {
          item.education = this.getValue(this.educationOptions, item.education)
          item.politicalOutlook = this.getValue(this.politicalOutlookOptions, item.politicalOutlook)
        });
        this.staffList = arr;
        this.total = response.total;
        this.loading = false;
      });
    },
    getValue(arr, item) {
      for (let i = 0; i < arr.length; i++) {
        console.log(i);
        if (item === arr[i].dictValue) {
          return arr[i].dictLabel
        }
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        gender: null,
        birthday: null,
        nativePlace: null,
        politicalOutlook: null,
        marriage: null,
        education: null,
        speciality: null,
        title: null,
        idCardNumber: null,
        graduationSchool: null,
        graduationTime: null,
        telephone: null,
        address: null,
        contactName: null,
        relationship: null,
        contactTelephone: null,
        personalPhotos: null,
        educationalPhotos: null,
        otherCertificatePhotos: null,
        skill: null,
        entryTime: null,
        post: null,
        probationSalary: null,
        fullMemberSalay: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        leavingCertificatePhotos: null,
        email: null,
        status: null,
        bank: null,
        bankCardNo: null,
        deptName: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加员工";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getStaff(id).then(response => {
        this.form = response.data;
        this.form.personalPhotosShow=process.env.VUE_APP_BASE_API +response.data.personalPhotos;
        this.form.leavingCertificatePhotosShow=process.env.VUE_APP_BASE_API +response.data.leavingCertificatePhotos;
        this.form.educationalPhotosShow=process.env.VUE_APP_BASE_API +response.data.educationalPhotos;
        this.form.otherCertificatePhotosShow=process.env.VUE_APP_BASE_API +response.data.otherCertificatePhotos;
        this.open = true;
        this.title = "修改员工";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateStaff(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStaff(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除员工编号为"' + ids + '"的数据项？').then(function() {
        return delStaff(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('module/staff/export', {
        ...this.queryParams
      }, `staff_${new Date().getTime()}.xlsx`)
    },

    // 获取学历
    getEducationOptions() {
      getDicts('biz_education').then(response => {
        this.educationOptions = response.data
      })
    },
    // 获取政治面貌
    getPoliticalOutlookOptions() {
      getDicts('biz_political_outlook').then(response => {
        this.politicalOutlookOptions = response.data
      })
    },
    // 覆盖默认的上传行为
    requestUpload() {
    },
    // 个人照片上传预处理
    beforeUpload(file) {
      console.log(file)
      let formData = new FormData()
      formData.append('imagefile', file)
      uploadImageFile(formData).then(response => {
        this.form.personalPhotos = response.imgUrl
        this.form.personalPhotosShow = process.env.VUE_APP_BASE_API + response.imgUrl
      })
    },
    // 学历上传预处理
    beforeUpload2(file) {
      console.log(file)
      let formData = new FormData()
      formData.append('imagefile', file)
      uploadImageFile(formData).then(response => {
        this.form.educationalPhotos = response.imgUrl
        this.form.educationalPhotosShow = process.env.VUE_APP_BASE_API + response.imgUrl
      })
    },
    // 离职证明上传预处理
    beforeUpload3(file) {
      console.log(file)
      let formData = new FormData()
      formData.append('imagefile', file)
      uploadImageFile(formData).then(response => {
        this.form.leavingCertificatePhotos = response.imgUrl
        this.form.leavingCertificatePhotosShow = process.env.VUE_APP_BASE_API + response.imgUrl
      })
    },
    // 其他证书上传预处理
    beforeUpload4(file) {
      console.log(file)
      let formData = new FormData()
      formData.append('imagefile', file)
      uploadImageFile(formData).then(response => {
        this.form.otherCertificatePhotos = response.imgUrl
        this.form.otherCertificatePhotosShow = process.env.VUE_APP_BASE_API + response.imgUrl
      })
    },
    onPreview (file) {
      this.ruleForm.imageUrl = file.url
      this.dialogVisible = true
    },
  }
};
</script>
